package com.sky.testmodule.controller;

import com.sky.testmodule.constant.TestConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName TestController
 * @Description 测试模块控制层
 * @Author zhiwei Liao
 * @Date 2021/8/712:12
 * @Version 1.0
 **/
@RequestMapping("/test/")
@RestController
public class TestController {

    @Autowired
    RedisTemplate redisTemplate;

    /**
     * 获取redis的值
     * @return
     */
    @GetMapping("/getRedisValue")
    public Object getRedisValue(){
        return redisTemplate.opsForValue().get(TestConstant.KEY_TEST);
    }

    /**
     * 设置redis
     */
    @GetMapping("/setRedisValue")
    public void setRedisValue(){
        redisTemplate.opsForValue().set(TestConstant.KEY_TEST,String.valueOf(System.currentTimeMillis()));
    }

}
